package com.pan.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

public enum ReadUtils {
    INSTANCE;

    public InputStream readResourceFile(String resourcesPath){
        InputStream resourceAsStream = ReadUtils.class.getClassLoader().getResourceAsStream(resourcesPath);
        return resourceAsStream;
    }

    public InputStream readFile(String path){
        File file = new File(path);
        if (!file.exists()){
            return null;
        }
        InputStream inputStream = null;
        try {
            FileInputStream fileInputStream = new FileInputStream(file);
            inputStream = fileInputStream;
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
        return inputStream;
    }

}
